<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%
    String zblx = Util.null2String( request.getParameter( "zblx" ) );
    String lc = Util.null2String( request.getParameter( "lc" ) );
    List<Map<String, String>> mapList = new ArrayList<>();
    JSONObject jsonData = new JSONObject();
    String sql = "select gysmc,swbl,jsbl,swf,jsf,zhdf,row_number() over( order by zhdf desc) as pm " +
            "from V_SRM_LGJ_ZH where xmmc=? and lc=? order by zhdf desc";
    rs.executeQuery( sql, zblx, lc );
    rs.writeLog( sql, String.join( ",", zblx, lc ) );
    while (rs.next()) {
        Map<String, String> dataMap = new HashMap<>();
        String gysmc = Util.null2String( rs.getString( "gysmc" ) );
        String gysmcname = getGysmc(gysmc);
        String swbl = Util.null2String( rs.getString( "swbl" ) );
        String jsbl = Util.null2String( rs.getString( "jsbl" ) );
        String swf = Util.null2String( rs.getString( "swf" ) );
        String jsf = Util.null2String( rs.getString( "jsf" ) );
        String zhdf = Util.null2String( rs.getString( "zhdf" ) );
        String pm = Util.null2String( rs.getString( "pm" ) );
        dataMap.put("gysmc",gysmc);
        dataMap.put("gysmcname",gysmcname);
        dataMap.put("swbl",swbl);
        dataMap.put("jsbl",jsbl);
        dataMap.put("swf",swf);
        dataMap.put("jsf",jsf);
        dataMap.put("zhdf",zhdf);
        dataMap.put("pm",pm);
        mapList.add(dataMap);
    }
    if(mapList.size()>0){
        jsonData.put("flag",true);
        jsonData.put("dataList",mapList);
    }
    out.print( jsonData.toJSONString() );
    bb.writeLog( "getPsjg_Ajax=" + jsonData.toJSONString() );
%>
<%!
    public static String getGysmc(String id) {
        RecordSet rs = new RecordSet();
        String gysmc = "";
        rs.executeQuery( "select gysmc from uf_srm_gyskpx where id='" + id + "'" );
        rs.next();
        gysmc = Util.null2String( rs.getString( "gysmc" ) );
        return gysmc;
    }

%>

